package com.hdd.fmh.common.context;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author HH
 * 业务层获取 HttpRequest对象方法
 */
public class ContextHolderUtils {
	
	public static ServletRequestAttributes rab= (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
	
	public static HttpServletRequest getRequest() throws Exception {
		HttpServletRequest request =null;
		try {
			request =rab.getRequest();
		} catch (Exception e) {
			throw new Exception("Request读取错误");
		}
		return request;
	}
	
	
	public static HttpServletResponse getResponse() throws Exception {
		HttpServletResponse response =null;
		try {
			response = rab.getResponse();
		} catch (Exception e) {
			throw new Exception("Response读取错误");
		}
		return response;
	}
}
